<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<script type="text/javascript" src="/${initParam.rootPath }/script/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#submitCmt").on("click", function(){
		$.ajax({
			"url": "/${initParam.rootPath }/reviewsboard/write_comment.do", 
			"type": "POST", 
			"data": "no=${requestScope.reviewsboard.no }&writer="+$("#wrt").val()+"&content="+$("#cmt").val(), 
			"dataType": "JSON", 
			"success": function(json){
				$("#comment").append("<div> 작성자 : "+json.comment.writer+" 일시 : "+json.comment.writedate+"<br>내용 : "+json.comment.content+"</div>");
			}
		});
	});
});
</script>
<link rel="stylesheet" type="text/css" href="/${initParam.rootPath }/css/show_post.css"/>
<h2>게시물</h2>

<div id="title" class="layer">
${requestScope.reviewsboard.no }.${requestScope.reviewsboard.title }
</div>
<div id="info" class="layer">
${requestScope.reviewsboard.writer }
</div>
<c:if test="${!empty requestScope.reviewsboard.filename }">
	<div id="image" class="layer">
		<c:forEach items="${fn:split(requestScope.filename, '/' )}" var="filename">
		<img align="middle" width="550px" src="/${initParam.rootPath }/upload_picture/${filename }"><br>
		</c:forEach>
	</div>
</c:if>
<div id="post" class="layer">
${requestScope.reviewsboard.content }
</div>
<div id="comment">
	<c:if test="${requestScope.reviewsboard.comment != null}">
		<c:forEach items="${requestScope.reviewsboard.comment }" var="cm">
			작성자 : ${cm.writer } 일시 : ${cm.writedate }<br>
			내용 : ${cm.content }<br>
		</c:forEach>
	</c:if>
</div>
<div>
<form>
<input type="hidden" id="wrt" value="${sessionScope.login_info.id }">
	<table>
		<tr>
			<td>
				<textarea rows="2" cols="70" maxlength="1000" id="cmt" 
				style="overflow: hidden; line-height: 14px; height: 61px;"></textarea>
			</td>
			<td>
				<img src="http://cafeimgs.naver.net/cafe4/btn_cmt_cfm_v1.gif" alt="확인" class="submitCmt" style="cursor: pointer;"
				 id="submitCmt">
			</td>
		</tr>
	</table>
</form>
</div>
<div style="margin-top: 30px">
	<a href="/${initParam.rootPath }/reviewsboard/list.do">목록</a> |
	<a href="/${initParam.rootPath }/reviewsboard/updateForm.do?no=${requestScope.reviewsboard.no }&page=${param.page }">수정</a> |
	<a href="/${initParam.rootPath }/reviewsboard/deletePost.do?no=${requestScope.reviewsboard.no }&page=${param.page }">삭제</a> |
</div>